<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>02_外间距测试</title>
    <style>/*        去掉body默认的margin自带的8px外间距*/
        body{
            margin: 0;
        }
    *{
        margin: 0;
        padding: 0;
    }
    .fu{
        background-color: rgba(255,255,0,.3);
        /*给父元素设置bfc结节保护*/
        overflow: hidden;
    }
    .fu>div{
        background-color: rgba(0,0,255,.5);
        height: 100px;
        width: 100px;
        border: 2px solid #00f;
        color: #fff;
        font-size: 25px;
        font-weight: bold;

    }
    .z1{
    margin-bottom: 30px;
        margin-top: 50px;
    }
    .z2{
        margin-top: 50px;
    }
    .z4{
        margin-bottom: 50px;
    }
    .z3{
        /*从上开始顺时针赋值，没有的找对面的*/
        margin: 10px;
        margin: 10px 20px;
        margin: 10px 20px 30px;
        margin: 10px 20px 30px 40px;
        margin:0 auto;
    }
    .s2{
        /*行内元素垂直方向上的外间距不成效！*/
        margin:30px;
    }

    </style>
</head>
<body>
<span>span1</span><span class="s2">span2</span><span>span3</span><span>span4</span>
<!--选中代码按Tab可以一起缩进 Shift+Tab可以缩减-->
<!--.fu>.z*4-->
    <div class="fu">
        <div class="z1">子元素1</div>
        <div class="z2">子元素2</div>
        <div class="z3">子元素3</div>
        <div class="z4">子元素4</div>
    </div>
<h1>哈哈哈</h1>
<input type="text">
<ul>
    <li>列表1</li>
    <li>列表1</li>
    <li>列表1</li>
    <li>列表1</li>
</ul>
</body>
</html>